package com.woniu.controller.advice;


import com.woniu.entity.HttpStatus;
import com.woniu.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class ExceptionAdvice {

    // 只要报异常，就会进入这个方法
    @ExceptionHandler
    public Result exceptionResole(Exception exception){
        log.debug("系统报异常了，异常为：" + exception.getMessage());
        exception.printStackTrace();
        return new Result(HttpStatus.ERROR, "出错，请联系管理员！");
    }

}
